home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
PASCAL
/
0514.ZIP
/
CRAYZ15.ARC
/
MPBLAS.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1986-09-15
|
6KB
|
197 lines
{ Copyright (C) 1986 Adam Fritz, 133 Main St., Afton, NY 13730 }
function ISAMAX ( n : integer ;
var sx : real ;
incx : integer ) : integer ;
{ Find index of element having maximum absolute value.}
{ }
{ Adam Fritz, TURBO Pascal, 8/02/86. }
var
smax : real ;
i, ix : integer ;
x : RowPointer ;
begin
ISAMAX := 0 ;
if n > 0 then begin
ISAMAX := 1 ;
if n > 1 then begin
{ incx > 1 }
if incx > 1 then begin
x := Ptr(Seg(sx),Ofs(sx)) ;
ix := 1 ;
smax := Abs(x^.s[1]) ;
ix := ix + incx ;
for i := 2 to n do begin
if Abs(x^.s[ix]) > smax then begin
ISAMAX := i ;
smax := Abs(x^.s[ix])
end ;
ix := ix + incx
end
end
{ incx = 1 }
else begin
MaxAVal (sx, smax, ix, n) ;
ISAMAX := ix
end
end
end
end ;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
function SASUM ( n : integer ;
var sx : real ;
incx : integer ) : real ;
{ Forms sum of absolute values. }
{ }
{ Adam Fritz, TURBO Pascal, 8/02/86. }
var
stemp : real ;
begin
stemp := 0.0 ;
if n > 0 then
{ incx > 1 }
if incx > 1 then
stemp := SumVABSSk (sx,incx,n)
{ incx = 1 }
else
stemp := SumVABS (sx,n) ;
SASUM := stemp
end ;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure SAXPY ( n : integer ;
sa : real ;
var sx : real ;
incx : integer ;
var sy : real ;
incy : integer ) ;
{ Compute constant times a vector plus a vector. }
{ }
{ Adam Fritz, TURBO Pascal, 8/02/86. }
var
i, ix, iy : integer ;
x, y : RowPointer ;
begin
if n > 0 then begin
if sa <> 0.0 then begin
{ incx <> incy or incx <> 1 }
if (incx <> 1) or (incy <> 1) then begin
x := Ptr(Seg(sx),Ofs(sx)) ;
y := Ptr(Seg(sy),Ofs(sy)) ;
ix := 1 ;
iy := 1 ;
if incx < 0 then
ix := (-n + 1) * incx + 1 ;
if incy < 0 then
iy := (-n + 1) * incy + 1 ;
for i := 1 to n do begin
y^.s[iy] := y^.s[iy] + sa * x^.s[ix] ;
ix := ix + incx ;
iy := iy + incy
end
end
{ incx, incy = 1 }
else
VAddKxV (sy,sy,sa,sx,n)
end
end
end ;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure SCOPY ( n : integer ;
var sx : real ;
incx : integer ;
var sy : real ;
incy : integer ) ;
{ Copies a vector, x, to a vector, y. }
{ }
{ Adam Fritz, TURBO Pascal, 8/02/86. }
begin
if n > 0 then
{ incx, incy <> 1 }
if (incx <> 1) or (incy <> 1) then
CopyVSk (sy,incy,sx,incx,n)
{ incx, incx = 1 }
else
CopyV (sy,sx,n)
end ;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
function SDOT ( n : integer ;
var sx : real ;
incx : integer ;
var sy : real ;
incy : integer ) : real ;
{ Computes dot product of two vectors. }
{ }
{ Adam Fritz, TURBO Pascal, 8/02/86. }
begin
if n > 0 then
SDOT := DotProd (sx,incx,sy,incy,n)
else
SDOT := 0.0
end ;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure SSCAL ( n : integer ;
sa : real ;
var sx : real ;
incx : integer ) ;
{ Computes vector scaled by a constant. }
{ }
{ Adam Fritz, TURBO Pascal, 8/02/86. }
begin
if n > 0 then
{ incx <> 1 }
if incx <> 1 then
KxVSk (sx,incx,sa,sx,incx,n)
{ incx = 1 }
else
KxV (sx,sa,sx,n)
end ;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure SSWAP ( n : integer ;
var sx : real ;
incx : integer ;
var sy : real ;
incy : integer ) ;
{ Interchanges two vectors. }
{ }
{ Adam Fritz, TURBO Pascal, 8/02/86. }
begin
if n > 0 then
{ incx <> incy or incx <> 1 }
if (incx <> 1) or (incy <> 1) then
SwapVSk (sx,incx,sy,incy,n)
{ incx, incy = 1 }
else
SwapV (sx,sy,n)
end ;
{ Copyright (C) 1986 Adam Fritz, 133 Main St., Afton, NY 13730 }